package com.cjy.common.exception;

import com.cjy.common.message.Code;

/**
 * @author Cheng JiYe
 * @description:
 * @date 2020/11/10 8:47
 */
@SuppressWarnings("ALL")
public class CommonException extends RuntimeException {
    private static final long serialVersionUID = 2967454088452931349L;
    /**
     * 错误码
     */
    private int code = Code.ReqFailure.getCode();
    /**
     * 错误信息
     */
    private String msg = Code.ReqFailure.getMsg();

    public Object object;

    public CommonException(Code code) {
        super("[" + code.getCode() + ":" + code.toString() + "]" + code.getMsg());
        this.code = code.getCode();
        this.msg = code.getMsg();
    }

    public CommonException(String msg) {
        super("[" + Code.ReqFailure.getCode() + ":" + Code.ReqFailure.toString() + "]" + msg);
        this.code = Code.ReqFailure.getCode();
        this.msg = msg;
    }

    public CommonException(Code code, String msg) {
        super("[" + code.getCode() + ":" + code.toString() + "]" + msg);
        this.code = code.getCode();
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }
}
